// eslint-disable-next-line
import { UserLayout, BasicLayout, RouteView } from '@/layouts'
import { bxAnaalyse } from '@/core/icons'

export const asyncRouterMap = [
  {
    path: '/',
    name: 'index',
    component: BasicLayout,
    meta: { title: '首页' },
    redirect: '/dashboard/workplace',
    children: [
      // dashboard
      {
        path: 'dashboard',
        name: 'dashboard',
        redirect: '/dashboard/Analysis',
        component: RouteView,
        meta: { title: '仪表盘', keepAlive: true, icon: bxAnaalyse, permission: ['dashboard'] },
        children: [
          {
            path: 'analysis',
            name: 'Analysis',
            component: () => import('@/views/dashboard/Analysis'),
            meta: { title: '分析页', keepAlive: false, permission: ['dashboard'] }
          },
          {
            path: 'workplace',
            name: 'Workplace',
            component: () => import('@/views/dashboard/Workplace'),
            meta: { title: '工作台', keepAlive: true, permission: ['dashboard'] }
          }
        ]
      },

      // 订单
      {
        path: 'order',
        name: 'order',
        component: RouteView,
        meta: { title: '订单', keepAlive: true, icon: 'file-text' },
        children: [
          // 订单管理
          {
            path: 'orderManage',
            name: 'OrderManage',
            component: RouteView,
            meta: { title: '订单管理', disable: true, keepAlive: false },
            children: [
              {
                path: 'orderGoods',
                name: 'OrderGoods',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '订货单', keepAlive: false }
              },
              {
                path: 'backOrder',
                name: 'BackOrder',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '退货单', keepAlive: true }
              }
            ]
          },
          // 订单统计
          {
            path: 'statistic',
            name: 'Statistic',
            component: RouteView,
            meta: { title: '订单统计', disable: true, keepAlive: true },
            children: [
              {
                path: 'record',
                name: 'Record',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '出库/发货记录', keepAlive: false }
              },
              {
                path: 'goodsMingXi',
                name: 'GoodsMingXi',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '订单商品统计（明细）', keepAlive: true }
              },
              {
                path: 'goodsKeHu',
                name: 'GoodsKeHu',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '订单商品统计（按客户）', keepAlive: true }
              },
              {
                path: 'goodsShangPin',
                name: 'GoodsShangPin',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '订单商品统计（按商品）', keepAlive: true }
              },
              {
                path: 'statisticFaHuo',
                name: 'StatisticFaHuo',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '发货统计', keepAlive: true }
              }
            ]
          },
          // 退单统计
          {
            path: 'backStatistic',
            name: 'BackStatistic',
            component: RouteView,
            meta: { title: '退单统计', disable: true, keepAlive: false },
            children: [
              {
                path: 'backGoods',
                name: 'BackGoods',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '退单商品统计', keepAlive: false }
              }
            ]
          },
          // 配送管理
          {
            path: 'delivery',
            name: 'Delivery',
            component: RouteView,
            meta: { title: '配送管理', disable: true, keepAlive: false },
            children: [
              {
                path: 'car',
                name: 'Car',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '车辆管理', keepAlive: false }
              },
              {
                path: 'task',
                name: 'Task',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '配送任务', keepAlive: false }
              }
            ]
          }
        ]
      },

      // 商品
      {
        path: 'goods',
        name: 'goods',
        component: RouteView,
        meta: { title: '商品', keepAlive: true, icon: 'shopping' },
        children: [
          // 商品管理
          {
            path: 'goodsManage',
            name: 'GoodsManage',
            component: RouteView,
            meta: { title: '商品管理', disable: true, keepAlive: false },
            children: [
              {
                path: 'goodsList',
                name: 'GoodsList',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '商品列表', keepAlive: false }
              }
            ]
          },
          // 库存管理
          {
            path: 'stock',
            name: 'Stock',
            component: RouteView,
            meta: { title: '库存管理', disable: true, keepAlive: true },
            children: [
              {
                path: 'goodsStock',
                name: 'goodsStock',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '商品库存', keepAlive: false }
              },
              {
                path: 'goodsIn',
                name: 'GoodsIn',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '商品入库', keepAlive: true }
              },
              {
                path: 'goodsOut',
                name: 'GoodsOut',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '商品出库', keepAlive: true }
              },
              {
                path: 'allot',
                name: 'Allot',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '库存调拨', keepAlive: true }
              },
              {
                path: 'check',
                name: 'Check',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '库存盘点', keepAlive: true }
              },
              {
                path: 'outInList',
                name: 'OutInList',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '出入库明细', keepAlive: true }
              },
              {
                path: 'goodsCount',
                name: 'GoodsCount',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '商品收发汇总', keepAlive: true }
              },
              {
                path: 'cost',
                name: 'Cost',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '成本调整', keepAlive: true }
              },
              {
                path: 'endCount',
                name: 'EndCount',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '期末结转', keepAlive: true }
              }
            ]
          },
          // 采购管理
          {
            path: 'buy',
            name: 'Buy',
            component: RouteView,
            meta: { title: '采购管理', disable: true, keepAlive: false },
            children: [
              {
                path: 'supply',
                name: 'Supply',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '供应商管理', keepAlive: false }
              },
              {
                path: 'aiBuy',
                name: 'AiBuy',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '智能采购', keepAlive: false }
              },
              {
                path: 'order',
                name: 'Order',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '采购订单', keepAlive: false }
              },
              {
                path: 'return',
                name: 'Return',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '采购退货', keepAlive: false }
              },
              {
                path: 'buyCount',
                name: 'BuyCount',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '采购汇总', keepAlive: false }
              }
            ]
          }
        ]
      },

      // 经销商
      {
        path: 'distributor',
        name: 'Distributor',
        component: RouteView,
        meta: { title: '经销商', keepAlive: true, icon: 'user' },
        children: [
          // 经销商管理
          {
            path: 'distributorManage',
            name: 'DistributorManage',
            component: RouteView,
            meta: { title: '经销商管理', disable: true, keepAlive: false },
            children: [
              {
                path: 'distributors',
                name: 'Distributors',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '经销商列表', keepAlive: false }
              },
              {
                path: 'opportunity',
                name: 'Opportunity',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '商机管理', keepAlive: false }
              },
              {
                path: 'feedback',
                name: 'Feedback',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '经销商反馈', keepAlive: false }
              }
            ]
          }
        ]
      },

      // 资金
      {
        path: 'fund',
        name: 'Fund',
        component: RouteView,
        meta: { title: '资金', keepAlive: true, icon: 'pay-circle' },
        children: [
          // 资金管理
          {
            path: 'fundManage',
            name: 'FundManage',
            component: RouteView,
            meta: { title: '资金管理', disable: true, keepAlive: false },
            children: [
              {
                path: 'receive',
                name: 'Receive',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '收款单', keepAlive: false }
              },
              {
                path: 'pay',
                name: 'Pay',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '付款单', keepAlive: false }
              },
              {
                path: 'receiveConfirm',
                name: 'ReceiveConfirm',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '收款确认', keepAlive: false }
              },
              {
                path: 'returnConfirm',
                name: 'ReturnConfirm',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '退款确认', keepAlive: false }
              },
              {
                path: 'fundAccount',
                name: 'FundAccount',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '资金账户', keepAlive: false }
              },
              {
                path: 'receiveAccount',
                name: 'ReceiveAccount',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '收款账户', keepAlive: false }
              },
              {
                path: 'otherFund',
                name: 'OtherFund',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '其他收支', keepAlive: false }
              }
            ]
          },
          // 对账管理
          {
            path: 'reconciliation',
            name: 'Reconciliation',
            component: RouteView,
            meta: { title: '对账管理', disable: true, keepAlive: false },
            children: [
              {
                path: 'dealerReconciliation',
                name: 'DealerReconciliation',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '经销商对账', keepAlive: false }
              },
              {
                path: 'dealerReconciliationPaper',
                name: 'DealerReconciliationPaper',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '经销商对账单', keepAlive: false }
              },
              {
                path: 'reconciliationRecord',
                name: 'ReconciliationRecord',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '核销记录', keepAlive: false }
              }
            ]
          },
          // 资金统计
          {
            path: 'fundCount',
            name: 'FundCount',
            component: RouteView,
            meta: { title: '资金统计', disable: true, keepAlive: false },
            children: [
              {
                path: 'fundList',
                name: 'FundList',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '收支明细', keepAlive: false }
              },
              {
                path: 'orderReceiveCount',
                name: 'OrderReceiveCount',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '订单收款统计', keepAlive: false }
              }
            ]
          }
        ]
      },

      // 营销
      {
        path: 'marketing',
        name: 'Marketing',
        component: RouteView,
        meta: { title: '营销', keepAlive: true, icon: 'deployment-unit' },
        children: [
          // 通知发布
          {
            path: 'pullNotice',
            name: 'PullNotice',
            component: RouteView,
            meta: { title: '通知发布', disable: true, keepAlive: false },
            children: [
              {
                path: 'advert',
                name: 'Advert',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '广告发布', keepAlive: false }
              },
              {
                path: 'notice',
                name: 'Notice',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '通知公告', keepAlive: false }
              },
              {
                path: 'message',
                name: 'Message',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '短信充值', keepAlive: false }
              },
              {
                path: 'noticeSet',
                name: 'NoticeSet',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '通知设置', keepAlive: false }
              }
            ]
          },
          // 促销管理
          {
            path: 'promotion',
            name: 'Promotion',
            component: RouteView,
            meta: { title: '促销管理', disable: true, keepAlive: false },
            children: [
              {
                path: 'goodsPromotion',
                name: 'GoodsPromotion',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '商品促销', keepAlive: false }
              },
              {
                path: 'orderPromotion',
                name: 'OrderPromotion',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '订单促销', keepAlive: false }
              },
              {
                path: 'composePromotion',
                name: 'ComposePromotion',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '组合促销', keepAlive: false }
              }
            ]
          },
          // 营销工具
          {
            path: 'marketingTools',
            name: 'MarketingTools',
            component: RouteView,
            meta: { title: '营销工具', disable: true, keepAlive: false },
            children: [
              {
                path: 'turnTable',
                name: 'TurnTable',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '大转盘', keepAlive: false }
              },
              {
                path: 'coupon',
                name: 'Coupon',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '优惠券', keepAlive: false }
              },
              {
                path: 'effect',
                name: 'Effect',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '效果分析', keepAlive: false }
              },
              {
                path: 'grade',
                name: 'Grade',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '积分', keepAlive: false }
              },
              {
                path: 'royalty',
                name: 'Royalty',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '拉新提成', keepAlive: false }
              }
            ]
          }
        ]
      },

      // 报表
      {
        path: 'report',
        name: 'Report',
        component: RouteView,
        meta: { title: '报表', keepAlive: true, icon: 'pie-chart' },
        children: [
          // 订货相关
          {
            path: 'orderAbout',
            name: 'OrderAbout',
            component: RouteView,
            meta: { title: '订货相关', disable: true, keepAlive: false },
            children: [
              {
                path: 'orderForm',
                name: 'OrderForm',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '订单统计报表', keepAlive: false }
              },
              {
                path: 'locationForm',
                name: 'LocationForm',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '地区统计报表', keepAlive: false }
              },
              {
                path: 'saleForm',
                name: 'SaleForm',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '商品销售报表', keepAlive: false }
              },
              {
                path: 'buyForm',
                name: 'BuyForm',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '经销商订货报表', keepAlive: false }
              }
            ]
          },
          // 利润损耗
          {
            path: 'profitExpend',
            name: 'ProfitExpend',
            component: RouteView,
            meta: { title: '利润损耗', disable: true, keepAlive: false },
            children: [
              {
                path: 'profit',
                name: 'Profit',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '销售毛利统计报表', keepAlive: false }
              },
              {
                path: 'expend',
                name: 'Expend',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '损耗统计报表', keepAlive: false }
              }
            ]
          },
          // 资金收款
          {
            path: 'fundReceive',
            name: 'FundReceive',
            component: RouteView,
            meta: { title: '资金收款', disable: true, keepAlive: false },
            children: [
              {
                path: 'shouldReceive',
                name: 'ShouldReceive',
                component: () => import('@/views/tmp/Tmp'),
                meta: { title: '应收统计报表', keepAlive: false }
              }
            ]
          }
        ]
      },

      // 应用中心（外部链接）
      {
        path: 'https://www.baidu.com/',
        name: 'APPStore',
        meta: { title: '应用中心', icon: 'shop', type: 'outLink' }
      },

      // Exception
      {
        path: '/exception',
        name: 'exception',
        component: RouteView,
        meta: { title: '异常页', icon: 'warning', permission: ['exception'] },
        children: [
          {
            path: '/exception/403',
            name: 'Exception403',
            component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/403'),
            meta: { title: '403', permission: ['exception'] }
          },
          {
            path: '/exception/404',
            name: 'Exception404',
            component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404'),
            meta: { title: '404', permission: ['exception'] }
          },
          {
            path: '/exception/500',
            name: 'Exception500',
            component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/500'),
            meta: { title: '500', permission: ['exception'] }
          }
        ]
      },

      // account
      {
        path: '/account',
        component: RouteView,
        name: 'account',
        meta: { title: '个人页', icon: 'user', keepAlive: true, permission: ['user'] },
        children: [
          {
            path: '/account/center',
            name: 'center',
            component: () => import('@/views/account/center/Index'),
            meta: { title: '个人中心', keepAlive: true, permission: ['user'] }
          },
          {
            path: '/account/settings',
            name: 'settings',
            component: () => import('@/views/account/settings/Index'),
            meta: { title: '个人设置', hideHeader: true, permission: ['user'] },
            redirect: '/account/settings/base',
            children: [
              {
                path: '/account/settings/base',
                name: 'BaseSettings',
                component: () => import('@/views/account/settings/BaseSetting'),
                meta: { title: '基本设置', hidden: true, permission: ['user'] }
              },
              {
                path: '/account/settings/security',
                name: 'SecuritySettings',
                component: () => import('@/views/account/settings/Security'),
                meta: { title: '安全设置', hidden: true, keepAlive: true, permission: ['user'] }
              },
              {
                path: '/account/settings/custom',
                name: 'CustomSettings',
                component: () => import('@/views/account/settings/Custom'),
                meta: { title: '个性化设置', hidden: true, keepAlive: true, permission: ['user'] }
              },
              {
                path: '/account/settings/binding',
                name: 'BindingSettings',
                component: () => import('@/views/account/settings/Binding'),
                meta: { title: '账户绑定', hidden: true, keepAlive: true, permission: ['user'] }
              },
              {
                path: '/account/settings/notification',
                name: 'NotificationSettings',
                component: () => import('@/views/account/settings/Notification'),
                meta: { title: '新消息通知', hidden: true, keepAlive: true, permission: ['user'] }
              }
            ]
          }
        ]
      }
    ]
  },
  {
    path: '*', redirect: '/404', hidden: true
  }
]

/**
 * 基础路由
 * @type { *[] }
 */
export const constantRouterMap = [
  {
    path: '/user',
    component: UserLayout,
    redirect: '/user/login',
    hidden: true,
    children: [
      {
        path: 'login',
        name: 'login',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Login')
      },
      {
        path: 'register',
        name: 'register',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Register')
      },
      {
        path: 'register-result',
        name: 'registerResult',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/RegisterResult')
      },
      {
        path: 'recover',
        name: 'recover',
        component: undefined
      }
    ]
  },

  {
    path: '/404',
    component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404')
  }
]
